﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing.Design;
using System.Windows.Forms;
using KpiConfigProject.TypeEditor.Controls;

namespace KpiConfigProject.TypeEditor
{
    public class FormulaTypeEditor : UITypeEditor
    {
        public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            FormulaEditorCtrl ctrl = new FormulaEditorCtrl();
            if (value!=null)
                ctrl.FormulaString = value.ToString();
            ctrl.ShowDialog();
            return base.EditValue(context, provider, ctrl.FormulaString);
        }

        public override UITypeEditorEditStyle GetEditStyle(System.ComponentModel.ITypeDescriptorContext context)
        {
            return UITypeEditorEditStyle.Modal;
        }        
    }
}
